﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace MySVN
{
    public partial class WebFormTai : System.Web.UI.Page
    {
        private DataClassesT6L6DataContext dc = new DataClassesT6L6DataContext();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            { loadData(); }
        }

        private void loadData()
        {
            GridView1.DataSource = dc.danhmucs.ToList();
            GridView1.DataBind();
        }

        protected void btnInsert_Click(object sender, EventArgs e)
        {
            danhmuc dm = new danhmuc();
            dm.tendm = txtTenDM.Text;
            dc.danhmucs.InsertOnSubmit(dm);
            dc.SubmitChanges();
            loadData();
        }
    }
}